package com.ruoyi.web.wapper;

import com.ruoyi.common.wapper.BaseControllerWrapper;
import org.apache.commons.lang3.ObjectUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Map;

public class SpecialDataStarCountInfoWapper extends BaseControllerWrapper {

    public SpecialDataStarCountInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public SpecialDataStarCountInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Integer starNumber = (Integer) map.get("starNumber");
            Integer star0Number = (Integer) map.get("star0Number");
            Integer star1Number = (Integer) map.get("star1Number");
            Integer star2Number = (Integer) map.get("star2Number");
            Integer star3Number = (Integer) map.get("star3Number");
            Integer star4Number = (Integer) map.get("star4Number");
            Integer star5Number = (Integer) map.get("star5Number");

            map.put("star0Rate", new BigDecimal(star0Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");
            map.put("star1Rate", new BigDecimal(star1Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");
            map.put("star2Rate", new BigDecimal(star2Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");
            map.put("star3Rate", new BigDecimal(star3Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");
            map.put("star4Rate", new BigDecimal(star4Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");
            map.put("star5Rate", new BigDecimal(star5Number).divide(new BigDecimal(starNumber),4, RoundingMode.DOWN).multiply(new BigDecimal(100)).setScale(2, RoundingMode.DOWN) + "%");

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
